/*
 * @Author: szx
 * @Date: 2021-11-21 13:43:10
 * @LastEditTime: 2021-11-21 15:15:27
 * @Description:
 * @FilePath: \leetcode\500-599\559\559.js
 */
/**
 * @param {Node|null} root
 * @return {number}
 */
var maxDepth = function (root) {
    if (!root) return 0;
    let res = 0;
    for (const child of root.children) {
        res = Math.max(res, maxDepth(child));
    }
    return res + 1;
};

var maxDepth = function (root) {
    if (!root) return 0;
    const queue = [];
    queue.push(root);
    let res = 0;
    while (queue.length) {
        let size = queue.length;
        for (let i = 0; i < size; i++) {
            const node = queue.shift();
            const children = node.children;
            for (const child of children) {
                queue.push(child);
            }
        }
        res++;
    }
    return res;
};
